using System;
using System.Runtime.CompilerServices;
using UnityEngine;
using UnityEngine.UI;
using Voodoo.Sauce.Internal.GDPR.Utils;

namespace Voodoo.Sauce.Internal.GDPR.UI
{
	public class VoodooGDPRMailScreen : MonoBehaviour
	{
		private enum MailType
		{
			Modify,
			Delete
		}

		private const string TAG = "VoodooGDPRMailScreen";

		[SerializeField]
		private MailType _mailType;

		[SerializeField]
		private InputField _idfaField;

		[SerializeField]
		private InputField _descriptionField;

		[SerializeField]
		private InputField _nameField;

		[SerializeField]
		private InputField _emailField;

		[CompilerGenerated]
		private static Action _003C_003Ef__mg_0024cache0;

		public void SendRequest()
		{
			if (VoodooGDPR.HasLimitAdTrackingEnabled())
			{
				VoodooGDPRCanvas.ShowMessageDialog("Error", "You have limited your ad tracking on your device settings. You cannot request this change.", null);
				return;
			}
			string text = _idfaField.text;
			string description = string.Empty;
			if (_descriptionField != null)
			{
				description = _descriptionField.text;
			}
			string text2 = _nameField.text;
			string text3 = _emailField.text;
			string action = (_mailType != 0) ? "delete" : "access";
			PrivacyRequestParams privacyRequestParams = new PrivacyRequestParams();
			privacyRequestParams.platform = VoodooGDPRUtils.GetOsType();
			privacyRequestParams.email = text3;
			privacyRequestParams.fullname = text2;
			privacyRequestParams.action = action;
			privacyRequestParams.description = description;
			privacyRequestParams.locale = VoodooGDPRUtils.GetLocale();
			privacyRequestParams.uuid = text;
			privacyRequestParams.appVersion = VoodooGDPRUtils.GetAppVersion();
			privacyRequestParams.vsVersion = VoodooGDPRUtils.GetVSVersion();
			privacyRequestParams.bundleId = Application.identifier;
			privacyRequestParams.studioName = "Voodoo";
			privacyRequestParams.gdprType = (int)VoodooGDPRUtils.GetGDPRType();
			VoodooGDPRAPI.PrivacyRequest(privacyRequestParams, delegate
			{
				VoodooGDPRCanvas.ShowMessageDialog("Success!", "Your mail has correctly been sent.", VoodooGDPRCanvas.CloseSettings);
			}, delegate(PrivacyRequest request)
			{
				if (string.Equals(request.errorMessage, "ALREADY_REQUESTED"))
				{
					VoodooGDPRCanvas.ShowMessageDialog("Error!", "You have already requested that information.", null);
				}
				else
				{
					VoodooGDPRCanvas.ShowMessageDialog("Error!", "An error occured, please try again later.", null);
				}
			});
		}
	}
}
